home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / BUSINESS / STATA3.LZH / QCKIT.TUT < prev    next >
Text File  |  1988-08-30  |  12KB  |  430 lines

  1. set output error
  2. set display page 23
  3. set more 1
  4. #delimit ;
  5.  
  6. di _n(13) in wh
  7. "  ___  ____  ____  ____  ____ tm" _n
  8. " /__    /   ____/   /   ____/" _n
  9. "___/   /   /___/   /   /___/    QC.Kit:  Programmed Extensions to Stata" _n
  10. "-----------------------------------------------------------------------"
  11. _n(2) ;
  12.  
  13. di in gr
  14. "QC.Kit is a collection of programs written in Stata that provides some useful"
  15. _n
  16. "quality control commands.  Although QC.Kit is written in Stata's programming"
  17. _n
  18. "language, you do not have to know anything about the programming language to"
  19. _n
  20. "use QC.Kit." _n ;
  21.  
  22. di in gr
  23. "If your computer and monitor do not have graphics capabilities, there is no" _n
  24. "reason to run this tutorial.  You can still use QC.Kit, but you will have to"
  25. _n
  26. "print the charts in order to see them.  This tutorial assumes that you will"
  27. _n
  28. "be able to see the charts as we draw them.  You can abort this tutorial by" _n
  29. "pressing "
  30. in wh "Break"
  31. in gr " (DOS users hold down "
  32. in wh "Ctrl" in gr " and press " in wh "Break"
  33. in gr ", Unix users hold down"
  34. _n
  35. in wh "Ctrl" in gr " and press " in wh "C"
  36. in gr ").  On the next screen, we will verify that Stata thinks your"
  37. _n
  38. "computer has graphics capabilities." _n ;
  39.  
  40. di in gr
  41. "If you are using a Sun under SunView, please "
  42. in wh "Break" in gr" out of this tutorial, type"
  43. _n
  44. "'" in wh "window define tut"
  45. in gr "', and then restart this tutorial.  You don't have to do" _n
  46. "that, but results will be better if you do.  (You may have already done this"
  47. _n
  48. "when you ran the graphics tutorial.  If so, you don't need to do it again.)"
  49. _n ;
  50.  
  51. #delimit cr
  52. mac def path
  53. capture run nullfile.tut
  54. if _rc {
  55.     mac def path "\stata\"
  56.     capture run %path`nullfile.tut
  57.     if _rc {
  58.         mac def path "/usr/stata/"
  59.         capture run %path`nullfile.tut
  60.         if _rc {
  61.             #delimit ;
  62.             di in red
  63. "I cannot find the other tutorial files.  I have looked in the current" _n
  64. "directory and in \stata (DOS) or /usr/stata (Unix).  Is Stata installed" _n
  65. "correctly?" _n(2)
  66. "In any case, I cannot run the tutorial." ;
  67.             #delimit cr
  68.             exit
  69.         }
  70.     }
  71. }
  72. macro define F5 "do %path`contents.tut;"
  73. macro define F6 "do %path`ourdata.tut;"
  74. #delimit ;
  75. set more 0 ; more ; set more 1 ;
  76.  
  77.  
  78. di _n(4) in wh
  79. "More preliminary" _n
  80. "----------------" _n(2)
  81. ". query" ;
  82. noisily query ;
  83.  
  84. di in gr _n
  85. "If the above display indicates that "
  86. in wh "graphics" in gr " are " in wh "off"
  87. in gr ", Stata does not think" _n
  88. "your computer and monitor have graphics capabilities, so you may as well" _n
  89. in wh "Break" in gr " out of this tutorial." _n ;
  90. set more 0 ; more ; set more 1 ;
  91.  
  92. drop _all ;
  93. label drop _all ;
  94. program drop _all ;
  95. macro define F6 "do %path`qckit.tut;" ;
  96.  
  97. di _n(10) in wh
  98. "Loading QC.Kit" _n
  99. "--------------" _n ;
  100.  
  101. di _n(2) in wh _dup(79) "-" _n in gr
  102. "Before you can use QC.Kit, you must load it:" _n
  103. in wh _dup(79) "-" _n(6)
  104. ". run %path`QC.Kit" ;
  105. run %path`QC.Kit ;
  106. di _n(2) ; set more 0 ; more ; set more 1 ;
  107.  
  108. di _n(4) in wh
  109. "Overview" _n
  110. "--------" _n ;
  111.  
  112. di in gr
  113. "QC.Kit provides three new commands:" _n(2)
  114. _col(8) in wh "cchart" in gr _col(20)
  115. "make a c-Chart" _n
  116. _col(8) in wh "pchart" in gr _col(20)
  117. "make a p-Chart" _n
  118. _col(8) in wh "plotebar" in gr _col(20) "make an error-bar chart" _n
  119. ;
  120.  
  121. di in gr
  122. "In most quality-control applications, you will want to tailor Stata to your"
  123. _n
  124. "environment.  You should therefore view QC.Kit not as an exhaustive list of"
  125. _n
  126. "Stata's capabilities, but as examples of the kinds of things you can do in" _n
  127. "Stata.  Since QC.Kit is written in Stata's programming language and is just" _n
  128. "an ASCII file, you can modify the commands to suit your application and you"
  129. _n
  130. "can add new ones." _n(2)
  131. "Right now, Stata is secretly loading some data which we will use to "
  132. "demonstrate" _n
  133. "QC.Kit. We will use data from the revised edition of "
  134. in ye "Quality Control and In" in gr "-" ;
  135. di in ye
  136. "dustrial Statistics" in gr
  137. " by Acheson J. Duncan.  We have data on the number of rail-"
  138. _n
  139. "way frames rejected from a random sample of 50 frames from each day's output."
  140. _n
  141. "These data cover the first 28 days in May." _n ;
  142.  
  143. input day rejects ;
  144. 1 4 ;
  145. 2 9 ;
  146. 3 10;
  147. 4 11;
  148. 5 13;
  149. 6 30;
  150. 7 26;
  151. 8 13;
  152. 9 8 ;
  153. 10 23;
  154. 11 34;
  155. 12 25;
  156. 13 18;
  157. 14 12;
  158. 15 4;
  159. 16 3;
  160. 17 11;
  161. 18 8 ;
  162. 19 14;
  163. 20 21;
  164. 21 25;
  165. 22 18;
  166. 23 10;
  167. 24 8;
  168. 25 18;
  169. 26 19;
  170. 27 4;
  171. 28 8;
  172. end;
  173. gen ssize=50 ;
  174. label data "Number rejected by day" ;
  175. label variable rejects "Number rejected" ;
  176. label var ssize "Sample size" ;
  177. label var day "Day" ;
  178. di _n in wh ". describe" ;
  179. set more 0 ; more  ; set more 1 ;
  180. noisily describe ;
  181. di _n in wh ". list in 1/7" ;
  182. noisily list in 1/7 ;
  183. di _n in wh ". summarize rejects, detail" ;
  184. set more 0 ; more ; set more 1 ;
  185. noisily summarize rejects, detail ;
  186. di _n in wh _dup(79) "-" _n in wh
  187. "pchart" in gr " will draw the p-Chart:" _n
  188. in wh _dup(79) "-" _n(2)
  189. ". pchart rejects day ssize, ylabel xlabel" ;
  190. set more 0 ; more ;
  191. pchart rejects day ssize, ylabel xlabel ;
  192. set more 1 ;
  193. replace ssize=2*(_N+mod(_n,9)) ;
  194.  
  195. di _n(2) in wh _dup(79) "-" _n in gr
  196. "The third variable in the "
  197. in wh "pchart" in gr " command specifies the sample size and "
  198. in wh "pchart" in gr _n
  199. "does not require that the sample sizes be the same across all days.  This tu-"
  200. _n
  201. "torial has silently changed the data, making the sample sizes vary:" _n
  202. in wh _dup(79) "-" _n(2)
  203. ". list in 1/6" ;
  204. noisily list in 1/6 ;
  205. di _n in wh ". pchart rejects day ssize, ylabel xlabel" ;
  206. set more 0 ; more ;
  207. pchart rejects day ssize, ylabel xlabel ;
  208. set more 1 ;
  209.  
  210. di _n(6) in wh _dup(79) "-" _n in gr
  211. "The syntax of the " in wh "pchart" in gr " command is" _n(2)
  212. _col(8) in wh "pchart " in gr "reject_var unit_var smplsize_var ["
  213. in wh ", stabilized " in gr "graph_options]" _n(2)
  214. "where the three variables record the number of items rejected, the unit that"
  215. _n
  216. "produced the sample, and the size of the sample that was inspected.  We have"
  217. _n
  218. "used the date of production as the unit_var, although the unit_var could just"
  219. _n
  220. "as well specify separate production units on the same day.  "
  221. in wh "pchart" in gr " allows all" _n
  222. "the options of " in wh "graph" in gr "'s " in wh "twoway"
  223. in gr " style, and we have specified "
  224. in wh "ylabel" in gr " and " in wh "xlabel" in gr "." _n
  225. "The "
  226. in wh "stabilized" in gr
  227. " option draws stabilized p-Charts when sample sizes vary:" _n
  228. in wh _dup(79) "-" _n(4)
  229. ". pchart rejects day ssize, xlabel ylabel stabilized title(May Production)"
  230. ;
  231. set more 0 ; more ;
  232. pchart rejects day ssize, xlabel ylabel stabilized title(May Production) ;
  233. set more 1 ;
  234. drop _all;
  235. input sample defects;
  236. 1  77;
  237. 2  64;
  238. 3  75;
  239. 4  93;
  240. 5  45;
  241. 6  61;
  242. 7  49;
  243. 8  65;
  244. 9  45;
  245. 10 77;
  246. 11 59;
  247. 12 54;
  248. 13 41;
  249. 14 87;
  250. 15 40;
  251. 16 22;
  252. 17 92;
  253. 18 89;
  254. 19 55;
  255. 20 25;
  256. 21 54;
  257. 22 22;
  258. 23 49;
  259. 24 33;
  260. 25 20;
  261. end;
  262. label data "Number of defects in 25 samples";
  263. label variable sample "Subassembly number";
  264. label variable defects "Number of defects";
  265.  
  266. di _n(2) in wh _dup(79) "-" _n in gr
  267. "QC.Kit can also draw c-Charts.  We'll use a slightly different data set to il-"
  268. _n
  269. "lustrate this, which this tutorial is now quietly loading.  These data record"
  270. _n
  271. "the number of defects per sample in 25 samples of 5 radio sets each:" _n
  272. in wh _dup(79) "-" _n(2)
  273. ". describe" ;
  274. noisily describe ;
  275. di _n in wh ". list in 1/5" ;
  276. noisily list in 1/5 ;
  277. set more 0 ; more ; set more 1 ;
  278.  
  279. di _n(2) in wh _dup(79) "-" _n in gr
  280. "The syntax of the "
  281. in wh "cchart" in gr " command is much like that of "
  282. in wh "pchart" in gr ":" _n(2)
  283. _col(8) in wh "cchart"
  284. in gr " defects_var unit_var [" in wh ", " in gr "graph_options]" _n(2)
  285. "In addition, all of Stata's Kit commands -- Stat.Kit, Graph.Kit, Data.Kit, and"
  286. _n
  287. "QC.Kit -- show the syntax of the command when it is typed without arguments:"
  288. _n
  289. in wh _dup(79) "-" _n(2)
  290. ". cchart" ;
  291. cchart ;
  292. di _n in wh
  293. ". cchart defects sample, ylabel xlabel title(c-Chart for Radio Subassemblies)" ;
  294. set more 0 ; more ;
  295. cchart defects sample, ylabel xlabel title(c-Chart for Radio Subassemblies) ;
  296. set more 1 ;
  297. drop _all ;
  298. input date mean std;
  299. 8.   192.21944   3.9370465;
  300. 9.   192.64444    2.833564;
  301. 10.   192.36667   4.5780769;
  302. 13.    194.7625   3.2508827;
  303. 14.   192.68889   2.8898289;
  304. 15.   195.01818   1.7303573;
  305. 16.   193.40278   2.6157595;
  306. end;
  307.  
  308. di _n(2) in wh _dup(79) "-" _n in gr
  309. "You can produce any kind of control chart with Stata and you can use Stata to"
  310. _n
  311. "produce other charts to help design and administer acceptance sampling plans"
  312. _n
  313. "or other quantitative chores." _n(2)
  314. "The " in wh "plotebar" in gr
  315. " command generates an error-bar chart.  This tutorial has once" _n
  316. "again secretly changed the data set so we could demonstrate this command:" _n
  317. in wh _dup(79) "-" _n(5)
  318. ". list" ;
  319. noisily list ;
  320. di _n in wh
  321. ". plotebar" ;
  322. set more 0 ; more ; set more 1 ;
  323. plotebar ;
  324. di _n(2) in wh
  325. ". plotebar mean std date, yline(195) title(Weight Variation) ylabel xlabel" ;
  326. set more 0 ; more ;
  327. plotebar mean std date, title(Weight variation) yline(195) ylabel xlabel
  328.     border tlab rlab ;
  329. set more 1 ;
  330.  
  331. drop _all ;
  332. input unit sum top bot;
  333.  1  -.367      .      . ;
  334.  2  -.649      .      . ;
  335.  3   -.75      .      . ;
  336.  4  -.617      .      . ;
  337.  5  -.797      .      . ;
  338.  6  -.672      .      . ;
  339.  7  -.259      .      . ;
  340.  8  -.015      .      . ;
  341.  9   .245      .      . ;
  342. 10   .583      .      . ;
  343. 11     .1      .      . ;
  344. 12   .342      .      . ;
  345. 13  -.148      .      . ;
  346. 14  -.587      .      . ;
  347. 15  -.472      .      . ;
  348. 16  -.496   .792  -.792 ;
  349. 17  -.659    .72   -.72 ;
  350. 18  -.319   .648  -.648 ;
  351. 19  -.576   .576  -.576 ;
  352. 20  -.684   .504  -.504 ;
  353. 21  -.766   .432  -.432 ;
  354. 22  -.224    .36   -.36 ;
  355. 23      .   .288  -.288 ;
  356. 24      .   .216  -.216 ;
  357. 25      .   .144  -.144 ;
  358. 26      .   .072  -.072 ;
  359. 27      .     0.     0. ;
  360. 28      .      .      . ;
  361. 29      .      .      . ;
  362. 30      .      .      . ;
  363. end ;
  364. label variable unit "Sample number" ;
  365. label variable sum "Cum. deviations" ;
  366. label variable top " " ;
  367. label variable bot " " ;
  368.  
  369. di _n(2) in wh _dup(79) "-" _n in gr
  370. "Finally, let's produce a cusum chart.  This time, rather than using a QC.Kit"
  371. _n
  372. "command, we'll just use Stata's "
  373. in wh "graph" in gr " command.  We've already performed some"
  374. _n
  375. "calculations using Stata so all we need to do is align our statistical data"
  376. _n
  377. "in a meaningful way to produce the cusum chart.  The main point is that Stata"
  378. _n
  379. "is often flexible enough to produce exactly the chart you need even though no"
  380. _n
  381. "Stata command explicitly performs the task:" _n
  382. in wh _dup(79) "-" _n(4)
  383. ". describe" ;
  384. noisily describe ;
  385. di _n in wh
  386. ". graph sum top bot unit, yline(0) ylabel xlabel c(.ll) s(oii)" ;
  387. set more 0 ; more ;
  388. format sum %8.1f ;
  389. graph sum top bot unit, yline(0) ylabel xlabel c(.ll) s(oii) pen(244) ;
  390. set more 1 ;
  391.  
  392.  
  393. di _n(2) in wh _dup(79) "-" _n in gr
  394. "Remember, these are only a small sample of the charts you can produce with"
  395. _n
  396. "Stata.  If you are seriously interested in automating a quality-control ap-"
  397. _n
  398. "plication, you will want to learn about Stata's programming language.  You" _n
  399. "can write programs in Stata that, at the touch of literally a single key," _n
  400. "will read data from disk, write reports, and draw graphs." _n(2)
  401. "For simple quality control applications, QC.Kit is probably enough.  QC.Kit,"
  402. _n
  403. "however, is written in Stata's programming language and you can modify it." _n
  404. "All of Stata's kits provide excellent examples of how to use Stata's program-"
  405. _n
  406. "ming language." _n
  407. in wh _dup(79) "-" _n(10) ;
  408. drop _all ;
  409. label drop _all ;
  410. macro define F6 "do %path`ourdata.tut;" ;
  411. set more 0 ; more ; set more 1 ;
  412.  
  413. di _n(4) in white
  414. "Demonstration ends" _n
  415. "------------------" _n ;
  416.  
  417.  
  418. di in green
  419. "That concludes our short demonstration, but there's much more.  We now return"
  420. _n
  421. "control to you.  Some suggestions:" _n ;
  422.  
  423. di in green
  424. "If you ..." _col(34) "Then we will show you ..." _n
  425. "    Press " in white "F5" in green _col(38) "a table of tutorial contents" _n
  426. "    Press " in white "F6" in green _col(38) "the next tutorial, "
  427. in white "ourdata.tut" _n ;
  428.  
  429. run %path`tobuy.tut ;
  430.